﻿<UserControl x:Class="Deployment.Data.UI.Controls.Environment.EnvironmentEditableList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:environment="clr-namespace:Deployment.Data.UI.Controls.Environment"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <ListView Name="lsv_Environments"
                  ItemsSource="{Binding Path=Environments}"
                  ClipToBounds="True"
                  VerticalAlignment="Stretch"
                  Grid.Column="0" SelectionChanged="lsv_Environments_SelectionChanged">
            <ListView.Resources>
                <Style TargetType="{x:Type GridViewColumnHeader}">
                    <Setter Property="HorizontalContentAlignment" Value="Left"/>
                </Style>
            </ListView.Resources>

            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Name"
                            Width="200"
                            DisplayMemberBinding="{Binding Name}"/>
                </GridView>
            </ListView.View>
        </ListView>
        <!--<environment:EnvironmentList x:Name="lsv_Environments2" 
                                     ItemsSource="{Binding Path=Environments, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True}" 
                                     ClipToBounds="True" ScrollViewer.CanContentScroll="True"
                                     VerticalAlignment="Stretch"
                                     Grid.Column="0" SelectionChanged="lsv_Environments_SelectionChanged"
                                     />-->
        <StackPanel Orientation="Vertical"
                    Grid.Column="1"
                    Margin="4,0,4,0"
                    VerticalAlignment="Stretch">
            <Button Content="Add environment" Padding="4,0,4,0" Click="AddEnvironement_Click"/>
            <Button Content="Remove selected" Margin="0,4,0,0" Click="RemoveEnvironment_Click">
                <Button.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger
                                    Binding="{Binding ElementName=lsv_Environments, Path=SelectedIndex}"
                                    Value="-1">
                                <Setter Property="Button.IsEnabled" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
            <Button Content="Clone selected" Margin="0,4,0,0" Click="CloneEnvironment_Click">
                <Button.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger
                                    Binding="{Binding ElementName=lsv_Environments, Path=SelectedIndex}"
                                    Value="-1">
                                <Setter Property="Button.IsEnabled" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </StackPanel>
    </Grid>
</UserControl>
